const modalPlugin = requirePlugin('xlightPlugin');
Component({
  props: {
    onAdInstance: () => {},
		onAdLoad: () => {},
		onAdError:()=>{},
		 onSuccess: () => { },
		  onClose: () => { },
		  add:()=>{}
		
		
		 
  },
  data: {
		interstitialAd: {}
  },
  onInit() {
	 
	const ad = new modalPlugin.CreateInterstitialAd();
	this.props.onAdInstance && this.props.onAdInstance(ad);
	this.setData({
		interstitialAd: ad
	})
	
	this.data.interstitialAd.onLoad(() => {

		console.log('ad onLoad')
		
		this.props.onAdLoad()
	})
	
	this.data.interstitialAd.onClose((isClick) => {
	  console.log('close', isClick);
	  this.props.onClose()
	});
	     // 广告加载成功
	        this.data.interstitialAd.onSuccess(() => {
	          this.props.onSuccess()
	        });
	

	this.data.interstitialAd.onError((err) => {
	  console.log('error', err);
	  this.props.onAdError(err)
	   
	 
	});
  },
  methods: {
    onInsuranceStatus(){
      console.log("用户完成了投保动作")
	  this.props.success('投保成功')
	   
    },
  },
});
